/*
 * @Author: szx
 * @Date: 2022-03-28 13:59:22
 * @LastEditTime: 2022-03-28 14:05:15
 * @Description:
 * @FilePath: \leetcode\剑指offer\57\57_II.js
 */
/**
 * @param {number} target
 * @return {number[][]}
 */
var findContinuousSequence = function (target) {
    const mid = Math.round(target / 2);
    const res = [];
    let i = 1;
    let sum = 1;
    for (let j = 2; j <= mid; j++) {
        sum += j;
        while (sum > target) {
            sum -= i;
            i++;
        }
        if (sum == target) res.push(new Array(j - i + 1).fill(0).map((_, index) => index + i));
    }
    return res;
};
console.log(findContinuousSequence(9));
